package top.IT00544.utils;
/**
 * 转换十六位数以内的整数
 * （进行中）
 * @author universe
 *
 */
public class ConveNumbers {

	/**
	 *    亿                          万    千 百 十     
	 * 0000  0000  0000  0 0 0 0
	 */
	private String[]num = new String[16];
	private String[]numa = {"0","1","2","3","4","5","6","7","8","9"};
//	〇  零
	private final String[]numb = {"零","一","二","三","四","五","六","七","八","九"};
	private String[]numb1 = {"十","百","千","万","亿"}; 
	private String[]numc = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
	private String[]numc1 = {"拾","佰","仟"};
	private String snum = "九千八百七十六";
	private int inum;
	
	public int convSnum4(String strNum) {
//		char[]c = strNum.toCharArray();
		String snum = "";
		String[]sarr = strNum.split(numb[0]);
		for(String stmp:sarr) {
			convSnum4b(stmp, snum);
		}
		return Integer.parseInt(snum);
	}
	private void convSnum4b(String strNum,String snum) {
		String[]stmp = strNum.split(numb1[2]);
		if(stmp.length == 2) {
			snum += match_StoI(stmp[0]);
			strNum = stmp[1];
		}else {
			strNum = stmp[0];
		}
		stmp = strNum.split(numb1[1]);
		if(stmp.length == 2) {
			snum += match_StoI(stmp[0]);
			strNum = stmp[1];
		}else {
			strNum = stmp[0];
		}
		stmp = strNum.split(numb1[0]);
		if(stmp.length == 2) {
			snum += match_StoI(stmp[0]);
			snum += match_StoI(stmp[1]);
		}else{
			snum += match_StoI(stmp[0]);
			if(strNum.contains(numb1[0])) {
				snum += numa[0];
			}
			
		}
	}
	
	private String match_StoI(String str) {
		switch(str) {
		case "零":str = numa[0];break;
		case "一":str = numa[1];break;
		case "二":str = numa[2];break;
		case "三":str = numa[3];break;
		case "四":str = numa[4];break;
		case "五":str = numa[5];break;
		case "六":str = numa[6];break;
		case "七":str = numa[7];break;
		case "八":str = numa[8];break;
		case "九":str = numa[9];break;
		}
		return str;
	}
	
	public static void main(String[] args) {
		ConveNumbers cn = new ConveNumbers();
		String str = "";
		str = "" + cn.convSnum4("九千八百七十六");
		System.out.println(str);
		str = "" + cn.convSnum4("八百七十六");
		System.out.println(str);
		str = "" + cn.convSnum4("八百零六");
		System.out.println(str);
		str = "" + cn.convSnum4("七十六");
		System.out.println(str);
		str = "" + cn.convSnum4("七十");
		System.out.println(str);
		str = "" + cn.convSnum4("六");
		System.out.println(str);
	}
}
